#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
#define icc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
void solve()
{
	int q=0;
	cin>>q;
	int f=0;
	ll hl=0,hr=1e18;
	while(q--)
	{
		ll op,a,b,n;
		cin>>op;
		ll l=0,r=0;
		if(op==1)
		{
			cin>>a>>b>>n;
			l=(a-b)*(n-2)+a+1;
			r=(a-b)*(n-1)+a;
            if(n==1) l=1;
            if(l>hr || r<hl)
            {
            	cout<<0<<' ';
			}
			else
			{
				cout<<1<<' ';
				hr=min(r,hr);
				hl=max(l,hl);
				f=1;
			}
			//cout<<hl<<' '<<hr<<endl;
               
		}
		else
		{
			cin>>a>>b;
			if(!f)
			{
				cout<<-1<<endl;
				continue;
			}
			if(hr<=a)
			{
				cout<<1<<' ';
			}
			else
			{
			    ll  LL=1;
			    ll  rr=hl;
			    int d1=0;
			    int d2=0;
			    while(LL<rr)
			    {
			    	ll mid=LL+rr>>1;
			    	if(__int128_t(mid-1)*(a-b)+a>=hl) rr=mid;
			    	else LL=mid+1; 
				}
				d1=LL;
				LL=1;
				rr=hr;
				while(LL<rr)
			    {
			    	ll mid=LL+rr>>1;
			    	if(__int128_t(mid-1)*(a-b)+a>=hr) rr=mid;
			    	else LL=mid+1; 
				}
				d2=LL;
				if(d1==d2)
				{
					cout<<LL<<' ';
				}
				
				else cout<<-1<<' ';
			}
		}
		
	 } 
	 cout<<endl;
}
int main()
{
	int t=0;
	cin>>t;
	while(t--)
	{
	
		solve();
	}

	return 0;
}

